<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" isELIgnored="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>添加管理员</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link rel="shortcut icon" href="favicon.ico"> 
    <link href="${pageContext.request.contextPath }/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="${pageContext.request.contextPath }/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <!-- jqgrid-->
    <link href="${pageContext.request.contextPath }/css/plugins/jqgrid/ui.jqgrid.css?0820" rel="stylesheet">
    <link href="${pageContext.request.contextPath }/css/animate.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath }/css/style.css?v=4.1.0" rel="stylesheet">
    <!-- 日期插件样式 -->
    <link href="${pageContext.request.contextPath }/css/foundation-datepicker.css" rel="stylesheet">
    <script src="${pageContext.request.contextPath }/js/jquery.min.js?v=2.1.4"></script>
    <script src="${pageContext.request.contextPath }/js/bootstrap.min.js?v=3.3.6"></script>
    
    <!-- 自定义js -->
    <script src="${pageContext.request.contextPath }/js/content.js?v=1.0.0"></script>
    <!-- jQuery Validation plugin javascript-->
    <script src="${pageContext.request.contextPath }/js/plugins/validate/jquery.validate.min.js"></script>
    <script src="${pageContext.request.contextPath }/js/plugins/validate/messages_zh.min.js"></script>
    <script src="${pageContext.request.contextPath }/js/plugins/layer/layer.min.js"></script>
    <!-- 日期插件js-->
    <script src="${pageContext.request.contextPath }/js/foundation-datepicker.js" type="text/javascript"></script>
     
	<style>
		input,select{
			 width:168px;
			 height:25px;
			 border:1px solid #ccc;
			 margin-left:24px;
		}
		.label-text{
			width:80px;
			text-align:right;
		}
		.form-item{
			display:flex;
		}
		.label-text{
		   height: 34px;
		   line-height: 34px;
		   font-weight: normal;
		}
		.addInput,
		.demo-3{ 
			background-color: #ffffff;
		    background-image: none;
		    border: 1px solid #e5e6e7;
		    border-radius: 1px;
		    color: inherit;
		    display: block;
		    font-size: 14px;
		    padding: 6px 12px;
		    transition: border-color 0.15s ease-in-out 0s, box-shadow 0.15s ease-in-out 0s;
		    height: 34px;
		   line-height: 34px;
		   flex: 1;
		}
		.saveBtn{
			 display: block;
		    margin: 15px auto;
		    width: 120px;
		}
		.pass-box{
			margin-left: 24px;
			flex: 1;
		}
	</style>
</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content  animated fadeInRight">
        <div class="row">
            <div class="col-sm-6">
                <div class="social-feed-box">
                    <div class="social-footer">
						<form name = "form1" id = "add_company"  enctype='multipart/form-data'>
							<input type = "hidden" name = "cId" id = "cId" value = "${company.id }"  ><br/><br/>
							<label  class="label-text">视频：</label>
								<input type='file' name='file'>
							<label class="label-text">名称：</label>
								<input type = "text" name = "name" id = "name" value = "${company.name }"/><br/><br/>
							<label class="label-text">展示时间：</label>
								<input type = "text" name = "showDate" id="showDate" class="demo-3"/><br/><br/>
							<label class="btn btn-primary" onclick = "updateCompany()">保存</label>
					    </form>
                    </div>
                </div>
            </div>
        </div>
    </div>

</body>

    
    <script type="text/javascript">
 
 	function cancel(){
 		var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
        parent.layer.close(index);
 	}
      
	//添加或修改
	function updateCompany(){	
		var formData = new FormData($( "#add_company" )[0]);  
    	$.ajax({ 
    		processData: false,  
            contentType: false,  
    	    url : "${pageContext.request.contextPath }/admin/company/upload",  
    	    data:formData, 
    	    type : "POST",  
      		async: false,  
            cache: false,   
    	    success : function(data) { 
	   	    	 if(data==0){
	   				layer.alert('上传成功!',{icon:1});
	   				searchCompany();
	   	    	 }else if(data==1){
					layer.msg('系统错误，上传失败!',{icon:0});
				 }else {
					layer.msg('上传视频失败',{icon:0});
				 }
	   	     },  
	   	     error : function(data) {
	   	    	 alert("系统错误，上传失败");
	   	     }  
    	});

	}
	</script>
	<script type="text/javascript">
		function formatDate(date, format) {
			if (!date) return;
			if (!format) format = "yyyy-MM-dd";
			switch (typeof date) {
				case "string":
					date = new Date(date.replace(/-/, "/"));
					break;
				case "number":
					date = new Date(date);
					break;
			}
			if (!date instanceof Date) return;
			var dict = {
				"yyyy": date.getFullYear(),
				"M": date.getMonth() + 1,
				"d": date.getDate(),
				"H": date.getHours(),
				"m": date.getMinutes(),
				"s": date.getSeconds(),
				"MM": ("" + (date.getMonth() + 101)).substr(1),
				"dd": ("" + (date.getDate() + 99)).substr(1),
				"HH": ("" + (date.getHours() + 110)).substr(1),
				"mm": ("" + (date.getMinutes() + 100)).substr(1),
				"ss": ("" + (date.getSeconds() + 100)).substr(1)
			};
			return format.replace(/(yyyy|MM?|dd?|HH?|ss?|mm?)/g, function() {
				return dict[arguments[0]];
			});
		}
		var webVal = $("#showDate").val();
		var c = formatDate(webVal, "yyyy-MM-dd HH:mm:ss");
		$("#showDate").val(c);
	</script>
	<script>
		var nowTemp = new Date();
		var now = new Date(nowTemp.getFullYear(), nowTemp.getMonth(), nowTemp.getDate(), nowTemp.getHours(), nowTemp.getMinutes(), 0, 0);
		$('.demo-3').fdatepicker({
			format: 'yyyy-mm-dd hh:ii',
			pickTime: true,
			onRender: function (date) {
				return date.valueOf() < now.valueOf() ? 'disabled' : '';
			}
		});
	</script>
</html>
